package com.wise.service.cms.content.article;

import com.wise.entities.content.Article;
import com.wise.entities.content.ArticleStatus;
import com.wise.framework.basic.DateTimeUtil;
import com.wise.framework.daomodel.DaoOne;
import com.wise.framework.daomodel.DaoOne4Update;
import com.wise.framework.daomodel.DaoSave;
import com.wise.framework.exception.LogicException;
import com.wise.framework.session.CurrentUserId;
import com.wise.summer.v1.cms.content.article.CopyArticle;
import com.wise.summer.v1.cms.content.article.JudgeArticle;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.summerframework.model.SummerService;
import org.summerframework.model.SummerServiceBean;

import java.util.Objects;

import static com.wise.model.content.ContentErrMsgs.Err_001600250007;
import static com.wise.model.content.ContentErrMsgs.Err_001600250019;

/**
 * @author Pitaya
 * @date 2019-11-15
 */

@Service
@SummerService
public class JudgeArticleService implements SummerServiceBean<JudgeArticle> {
    @Override
    public void sum(JudgeArticle model) {
        //权限
        //TODO
        //修改状态
        Article article = DaoOne4Update.s(Article.class, model.getId(), Err_001600250007);
        if (Objects.equals(model.getState(), ArticleStatus.success.value())) {
            article.setState(ArticleStatus.success.value());
        }else {
            article.setState(ArticleStatus.NOTPUBLISH.value());
        }
        DaoSave.s(article);



    }
}
